{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "URL: http://bokeh.pydata.org/en/latest/docs/gallery/texas.html\n",
    "\n",
    "Most examples work across multiple plotting backends, this example is also available for:\n",
    "\n",
    "* [Bokeh - texas choropleth example](../bokeh/texas_choropleth_example.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import holoviews as hv\n",
    "hv.extension('matplotlib')\n",
    "%output fig='svg'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Declaring data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from bokeh.sampledata.us_counties import data as counties\n",
    "from bokeh.sampledata.unemployment import data as unemployment\n",
    "\n",
    "counties = {\n",
    "    code: county for code, county in counties.items() if county[\"state\"] == \"tx\"\n",
    "}\n",
    "\n",
    "county_xs = [county[\"lons\"] for county in counties.values()]\n",
    "county_ys = [county[\"lats\"] for county in counties.values()]\n",
    "\n",
    "county_names = [county['name'] for county in counties.values()]\n",
    "county_rates = [unemployment[county_id] for county_id in counties]\n",
    "\n",
    "county_polys = {name: hv.Polygons((xs, ys), level=rate, vdims=['Unemployment'])\n",
    "                for name, xs, ys, rate in zip(county_names, county_xs, county_ys, county_rates)}\n",
    "\n",
    "choropleth = hv.NdOverlay(county_polys, kdims=['County'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot_opts = dict(logz=True, xaxis=None, yaxis=None,\n",
    "                 show_grid=False, show_frame=False, fig_size=200, bgcolor='white')\n",
    "style = dict(edgecolor='white')\n",
    "\n",
    "choropleth({'Polygons': {'style': style, 'plot': plot_opts}})"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
